package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.mapper.AddressMapper;
import cn.tedu.egmvc1.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address/")
public class AddressController {
    @Autowired(required = false)
    private AddressMapper addressMapper;
    //1.添加收货地址
    @RequestMapping("insert")
    public String insert(Address address){
        addressMapper.insertAddress(address);
        return "添加成功！";
    }
    //2.查询收货地址
    @RequestMapping("select")
    public List<Address> select(){
        return addressMapper.selectAddress();
    }
    //3.删除收货地址
    @RequestMapping("delete")
    public String delete(){
        addressMapper.deleteAddress(1);
        return "删除成功！";
    }
    //4.修改收货地址
    @RequestMapping("update")
    public String update(Address address){
        addressMapper.updateAddress(address);
        return "修改成功";
    }
}
